package com.sb.framework.bean;

import com.alan.validate.model.IValidErrorEntiy;
import com.sb.framework.exception.BusinessException;

/**
 * 
 * @author wzh
 * @version 1.0
 * @param <T>
 */
@SuppressWarnings("all")
public class RespResult<T> extends RestStatus implements IValidErrorEntiy<RespResult<T>> {

	public T detail;

	public RespResult() {
		super();
	}

	public RespResult(String code, String message) {
		super( code, message );
	}

	public RespResult(String code, String message, T bean) {
		super( code, message );
		this.detail = bean;
	}

	public T getDetail() {
		return detail;
	}

	public void setDetail(T detail) {
		this.detail = detail;
	}

	public static RespResult buildSuccessResult(Object bean) {
		return new RespResult( ErrorCode.SUCCESS, RestStatus.CODE_200_MSG, bean );
	}

	public static RespResult buildErrorResult(String errorCode, String message) {
		return new RespResult( errorCode, message );
	}

	public static RespResult buildErrorResult(BusinessException businessException) {
		return new RespResult( businessException.getCode(), businessException.getMessage() );
	}

	@Override
	public RespResult<T> ReturnMessage(String message) {
		RespResult respResult = new RespResult<T>( ErrorCode.PARAM_VALID_FAIL, message );
		return respResult;
	}

}